package com.mycompany.j2eem.service.ghyservice;

import com.mycompany.j2eem.Entity.JsonResult;
import com.mycompany.j2eem.Entity.ResultCode;
import com.mycompany.j2eem.Entity.bean.PicInfo;
import com.mycompany.j2eem.Mapper.ghymapper.PictureStoreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jws.soap.SOAPBinding;
import javax.websocket.Session;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
public class PictureStoreService {

    @Autowired
    PictureStoreMapper pictureStoreMapper;

    //收藏图片
    public JsonResult ConcernPicture(String account_id, String picture_id) {
        pictureStoreMapper.Conner_picture(account_id, picture_id);
        return new JsonResult(ResultCode.SUCCESS);
    }
    //取消收藏
    public JsonResult deConcernPicture(String account_id, String picture_id) {
        pictureStoreMapper.Delete_Conner_picture(account_id, picture_id);
        return new JsonResult(ResultCode.SUCCESS);
    }
    //返回发布信息
    public List personalMovementInfo(String account_id){
        //pictureStoreMapper.getMovement(account_id);
        List<String> movementInfo=pictureStoreMapper.getMovement(account_id);
        return movementInfo;
    }
    //返回图片信息
    public PicInfo pictureInfo(String picture_id){
        List<String> picinfoTagName=pictureStoreMapper.getPictureTag(picture_id);
        String picinfoPath=pictureStoreMapper.getPicturePath(picture_id);
        String account_id=pictureStoreMapper.getAccountID(picture_id);
        PicInfo picInfo=new PicInfo(picinfoPath,picinfoTagName);
        picInfo.setUserName(account_id);
        picInfo.setPicName(pictureStoreMapper.getMovementName(account_id));

        if(pictureStoreMapper.getConnernedPicture(account_id)==null) {
            picInfo.setStar(false);
        }else{
            picInfo.setStar(true);
        }
        return picInfo;
    }

}
